from playLA.Vector import Vecotr

if __name__ == "__main__":
    vec = Vecotr([5,2])
    print(vec)
    print(len(vec))
    print("vec[0] = {} , vec[1] = {}".format(vec[0] , vec[1]))
    vec2 = Vecotr([3,1])
    print("{} + {} = {}".format(vec , vec2 , vec + vec2))
    print("{} - {} = {}".format(vec , vec2 , vec - vec2))
    print("{} * {} = {}".format(vec , 3 , vec * 3))
    print("{} * {} = {}".format(3, vec, 3 * vec))

    print("+{} = {}".format(vec, +vec))
    print("-{} = {}".format(vec, -vec))

    zero2 = Vecotr.zero(2)
    print(zero2)
    print("{} + {} = {}".format(vec , zero2 , vec + zero2))

    # 向量模
    print("norm({}) = {}".format(vec,vec.norm()))
    print("norm({}) = {}".format(zero2,zero2.norm()))

    # 单位向量
    print("normalize {} is {} ".format(vec , vec.normalize()))
    print(vec.normalize().norm())

    print("normalize {} is {} ".format(vec2 , vec2.normalize()))
    print(vec2.normalize().norm())

    try:
        print(zero2.normalize().norm())
    except ZeroDivisionError:
        print("Cannot normalize zero vector {}".format(zero2))

    # 点乘
    print(vec.dot(vec2))



